<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Player  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset='utf-8'>
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a title="Player  Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="index.html">Player Docs</a> (58% documented)</p>
        <p class="header-right"><a href="https://github.com/piemonte/Player"><img src="img/gh.png"/>View on GitHub</a></p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="index.html">Player Reference</a>
        <img id="carat" src="img/carat.png" />
        Player  Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Classes/Player.html">Player</a>
              </li>
              <li class="nav-group-task">
                <a href="Classes/PlayerView.html">PlayerView</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Global Variables.html">Global Variables</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Global Variables.html#/s:6Player0A11ErrorDomainSSvp">PlayerErrorDomain</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Enums/BufferingState.html">BufferingState</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/PlaybackState.html">PlaybackState</a>
              </li>
              <li class="nav-group-task">
                <a href="Enums/PlayerError.html">PlayerError</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Protocols/PlayerDelegate.html">PlayerDelegate</a>
              </li>
              <li class="nav-group-task">
                <a href="Protocols/PlayerPlaybackDelegate.html">PlayerPlaybackDelegate</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="Typealiases.html">Type Aliases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="Typealiases.html#/s:6Player0A8FillModea">PlayerFillMode</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            
            <p><img src="https://github.com/piemonte/Player/raw/master/Player.gif" alt="Player"></p>
<h2 id='player' class='heading'>Player</h2>

<p><code><a href="Classes/Player.html">Player</a></code> is a simple iOS video player library written in <a href="https://developer.apple.com/swift/">Swift</a>.</p>

<p><a href="https://travis-ci.org/piemonte/Player"><img src="https://travis-ci.org/piemonte/Player.svg?branch=master" alt="Build Status"></a> <a href="http://cocoadocs.org/docsets/Player/"><img src="https://img.shields.io/cocoapods/v/Player.svg?style=flat" alt="Pod Version"></a> <a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/language-swift%204.0-brightgreen.svg" alt="Swift Version"></a> <a href="https://github.com/piemonte/Player/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-lightgrey.svg" alt="GitHub license"></a></p>

<ul>
<li>Looking for an obj-c video player? Check out <a href="https://github.com/piemonte/PBJVideoPlayer">PBJVideoPlayer (obj-c)</a>.</li>
<li>Looking for a Swift camera library? Check out <a href="https://github.com/NextLevel/NextLevel">Next Level</a>.</li>
</ul>
<h3 id='features' class='heading'>Features</h3>

<ul>
<li>[x] plays local media or streams remote media over HTTP</li>
<li>[x] customizable UI and user interaction</li>
<li>[x] no size restrictions</li>
<li>[x] orientation change support</li>
<li>[x] simple API</li>
<li>[x] video frame snapshot support</li>
</ul>
<h1 id='quick-start' class='heading'>Quick Start</h1>

<p><code><a href="Classes/Player.html">Player</a></code> is available for installation using the Cocoa dependency manager <a href="http://cocoapods.org/">CocoaPods</a>.  Alternatively, you can simply copy the <code>Player.swift</code> file into your Xcode project.</p>
<pre class="highlight ruby"><code><span class="c1"># CocoaPods</span>
<span class="n">swift_version</span> <span class="o">=</span> <span class="s2">"4.0"</span>
<span class="n">pod</span> <span class="s2">"Player"</span><span class="p">,</span> <span class="s2">"~&gt; 0.9.0"</span>

<span class="c1"># Carthage</span>
<span class="n">github</span> <span class="s2">"piemonte/Player"</span> <span class="o">~&gt;</span> <span class="mi">0</span><span class="o">.</span><span class="mi">9</span><span class="o">.</span><span class="mi">0</span>
</code></pre>

<p>Need Swift 3? Use release <code>0.7.0</code></p>
<h2 id='usage' class='heading'>Usage</h2>

<p>The sample project provides an example of how to integrate <code><a href="Classes/Player.html">Player</a></code>, otherwise you can follow these steps.</p>

<p>Allocate and add the <code><a href="Classes/Player.html">Player</a></code> controller to your view hierarchy.</p>
<pre class="highlight plaintext"><code> self.player = Player()
 self.player.playerDelegate = self
 self.player.playbackDelegate = self
 self.player.view.frame = self.view.bounds

 self.addChildViewController(self.player)
 self.view.addSubview(self.player.view)
 self.player.didMove(toParentViewController: self)
</code></pre>

<p>Provide the file path to the resource you would like to play locally or stream. Ensure you&rsquo;re including the file extension.</p>
<pre class="highlight plaintext"><code>let videoUrl: URL = // file or http url
self.player.url = videoUrl
</code></pre>

<p>play/pause/chill</p>
<pre class="highlight plaintext"><code> self.player.playFromBeginning()
</code></pre>

<p>Adjust the fill mode for the video, if needed.</p>
<pre class="highlight plaintext"><code> self.player.fillMode = PlayerFillMode.resizeAspectFit.avFoundationType
</code></pre>

<p>Display video playback progress, if needed.</p>
<pre class="highlight plaintext"><code>extension ViewController: PlayerPlaybackDelegate {

    public func playerPlaybackWillStartFromBeginning(_ player: Player) {
    }

    public func playerPlaybackDidEnd(_ player: Player) {
    }

    public func playerCurrentTimeDidChange(_ player: Player) {
        let fraction = Double(player.currentTime) / Double(player.maximumDuration)
        self._playbackViewController?.setProgress(progress: CGFloat(fraction), animated: true)
    }

    public func playerPlaybackWillLoop(_ player: Player) {
        self. _playbackViewController?.reset()
    }

}
</code></pre>
<h2 id='documentation' class='heading'>Documentation</h2>

<p>You can find <a href="http://piemonte.github.io/Player/">the docs here</a>. Documentation is generated with <a href="https://github.com/realm/jazzy">jazzy</a> and hosted on <a href="https://pages.github.com">GitHub-Pages</a>.</p>
<h2 id='community' class='heading'>Community</h2>

<ul>
<li>Need help? Use <a href="http://stackoverflow.com/questions/tagged/player-swift">Stack Overflow</a> with the tag &lsquo;player-swift&rsquo;.</li>
<li>Questions? Use <a href="http://stackoverflow.com/questions/tagged/player-swift">Stack Overflow</a> with the tag &lsquo;player-swift&rsquo;.</li>
<li>Found a bug? Open an <a href="https://github.com/piemonte/player/issues">issue</a>.</li>
<li>Feature idea? Open an <a href="https://github.com/piemonte/player/issues">issue</a>.</li>
<li>Want to contribute? Submit a <a href="https://github.com/piemonte/player/pulls">pull request</a>.</li>
</ul>
<h2 id='resources' class='heading'>Resources</h2>

<ul>
<li><a href="https://github.com/apple/swift-evolution">Swift Evolution</a></li>
<li><a href="https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html">AV Foundation Programming Guide</a></li>
<li><a href="https://github.com/NextLevel/NextLevel/">Next Level</a>, rad media capture in Swift</li>
<li><a href="https://github.com/piemonte/PBJVision">PBJVision</a>, iOS camera engine, features touch-to-record video, slow motion video, and photo capture</li>
<li><a href="https://github.com/piemonte/PBJVideoPlayer">PBJVideoPlayer</a>, a simple iOS video player library, written in obj-c</li>
</ul>
<h2 id='license' class='heading'>License</h2>

<p>Player is available under the MIT license, see the <a href="https://github.com/piemonte/player/blob/master/LICENSE">LICENSE</a> file for more information.</p>

          </section>
        </section>
        <section id="footer">
          <p>&copy; 2018 <a class="link" href="https://patrickpiemonte.com" target="_blank" rel="external">Patrick Piemonte</a>. All rights reserved. (Last updated: 2018-09-04)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
